<?php
include 'DBconn.php';
class BranchMasterDetails{
    public function getAllBranches()
    {
        $result=mysql_query("select * from branch_header where activestatus=1") or die(mysql_error());
        $ret_arr=array();
        while($row=mysql_fetch_object($result)){
	$temp=new VoBranchMaster();
    $temp->serialnumber=(int)$row->serialnumber;
    $temp->company_serialnumber=(int)$row->company_serialnumber; 
    $temp->branch_name=$row->branch_name;
    $temp->branch_code=$row->branch_code;
    $temp->branch_email=$row->branch_email;
    $temp->branch_description=$row->branch_description;
    $temp->cre_userid=(int)$row->cre_userid;
    $temp->cre_datetime=$row->cre_datetime;
    $temp->activestatus=(boolean)$row->activestatus;
      //$temp->serialnumber=(int)$row->serialnumber;
//     $temp->emp_id=$row->emp_id;
//     $temp->user_name=$row->user_name;
//     $temp->login_name=$row->login_name;
//     $temp->user_password=$row->user_password;
//     $temp->user_designation=$row->user_designation;
//     $temp->user_department=$row->user_department;
//     $temp->user_role=$row->user_role;
//     $temp->user_email=$row->user_email;
//     $temp->user_image=$row->user_image;
//     $temp->isactive=(boolean)$row->isactive;
//     $temp->cre_userid=(int)$row->cre_userid;
//     $temp->cre_datetime=$row->cre_datetime;
//     $temp->activestatus=(boolean)$row->activestatus;
	$ret_arr[]=$temp;
}
      mysql_free_result($result);
return $ret_arr;  
  }
    public function addNewBranch($VObject)
    {
        $query="insert into branch_header(company_serialnumber,branch_name,branch_code,branch_email,branch_description,cre_userid,cre_datetime,activestatus) values (1,'$VObject->branch_name','$VObject->branch_code','$VObject->branch_email','$VObject->branch_description','$VObject->cre_userid','$VObject->cre_datetime',1)";
        $s=mysql_query($query) or die(mysql_error());
        if ($s=1) 
      {
        mysql_query("COMMIT");
      }
      else
      {
        mysql_query("ROLLBACK");
      }
        return 'true';    
        }
    public function editBranchDetails($VObject)
    {
        $query="update branch_header set company_serialnumber='$VObject->company_serialnumber',branch_name='$VObject->branch_name',branch_code='$VObject->branch_code',branch_email='$VObject->branch_email',branch_description='$VObject->branch_description',cre_userid='$VObject->cre_userid',cre_datetime='$VObject->cre_datetime' where serialnumber='$VObject->serialnumber'";
        $s=mysql_query($query) or die(mysql_error());
        if ($s=1) 
      {
        mysql_query("COMMIT");
      }
      else
      {
        mysql_query("ROLLBACK");
      }
        return 'true';   
    }
    public function deleteBranchDetails($VObject)
    {
        $s=mysql_query("update branch_header set activestatus=0 where serialnumber=".$VObject->serialnumber) or die(mysql_error());
        if ($s=1) 
      {
        mysql_query("COMMIT");
      }
      else
      {
        mysql_query("ROLLBACK");
      }
        return 'true';   
    }
}
//$vo=new VoBranchMaster;
//$vo->cre_userid=1;
//$vo->serialnumber=3;
//$vo->branch_code="1547";
//$vo->branch_email="abc@sdf.com";
//$d=new branchMasterDetails;
//#echo $d->addNewBranch($vo);
//#echo $d->deleteBranchDetails($vo);
//echo $d->editBranchDetails($vo);
class VoBranchMaster
{
    var $serialnumber;
    var $company_serialnumber;
    var $branch_name;
    var $branch_code;
    var $branch_email;
    var $branch_description;
    var $cre_userid;
    var $cre_datetime;
    var $activestatus;
}

?>